/******************* (C) COPYRIGHT 2022 CHU WEI TENG ***********************************************
**
**------------------ File Info ---------------------------------------------------------------------
** File name:      dwin_page.h
** modified Date:  2022-05-10
** Last Version:   V1.0
** Descriptions: 
** 
**------------------ Modfication  log --------------------------------------------------------------
** Date       Who            Rev        Comments
----------------------------------------------------------------------------------------------------
   22/05/10  chuwt@qq.com    V1.00      created

****************************************************************************************************/
#ifndef __DWIN_PAGE_H__
#define __DWIN_PAGE_H__

#include "dwin_widget.h"

/* Public define-----------------------------------------------------------------------------------*/

/* Public typedef----------------------------------------------------------------------------------*/
typedef ret_t (*page_ops_t)(dwin_widget_t* page);

/**
 * @class   dwin_page_t
 * @parent  diwn_widget_t
 * @node    抽象类不要实例化
**/
typedef struct
{
    dwin_widget_t   widget; 
    dwin_list_t     list;
    uint16_t        reg_id;
    uint16_t        page_id;
    uint16_t        is_open;
    page_ops_t      open;
    page_ops_t      close;
    page_ops_t      read;
    page_ops_t      write;
    page_ops_t      run;
}dwin_page_t;

/* Public function---------------------------------------------------------------------------------*/
ret_t dwin_page_init(dwin_widget_t* page, uint16_t page_id, uint16_t addr, uint16_t attr, uint16_t size);
ret_t dwin_page_widget_add(dwin_widget_t* page, dwin_widget_t* widget);
ret_t dwin_page_widget_remove(dwin_widget_t* widget);

ret_t dwin_page_open(dwin_widget_t* page);
ret_t dwin_page_close(dwin_widget_t* page);
ret_t dwin_page_read(dwin_widget_t* page);
ret_t dwin_page_write(dwin_widget_t* page);
ret_t dwin_page_run(dwin_widget_t* page);
ret_t dwin_page_jump(dwin_widget_t* page);
ret_t dwin_page_jump_id(uint16_t page_id);

#endif
